package com.anzia.generic;

/**
 *@ClassName TestGeneric
 *@Description
 *@Author Anzia.
 *@Date 2021/4/10 12:49
 *@Version 1.0
 **/
public class TestGeneric {
    public static void main(String[] args) {
        //使用泛型类创建对象
        MyGeneric<String> myGeneric = new MyGeneric<>();
        myGeneric.t = "hello";
        myGeneric.show("大家好！");
        String t = myGeneric.getT();
        System.out.println(t);

        MyGeneric<Integer> myGeneric1 = new MyGeneric<>();
        myGeneric1.t = 100;
        myGeneric1.show(200);
        Integer t1 = myGeneric1.getT();
        System.out.println(t1);

        //泛型接口的泛型
        MyInterfaceImpl myInterface = new MyInterfaceImpl();
        myInterface.server("xxxxxxx");
        MyInterfaceImpl2<Integer> myInterfaceImpl2 = new MyInterfaceImpl2<>();
        myInterfaceImpl2.server(1000);

        //泛型方法
        MyGenericMethod method = new MyGenericMethod();
        method.show("Java第一");
        method.show(1024);
        method.show(3.14);
    }
}
